﻿//选择部门弹窗 选择 部门或公司 或人员 单选或多选
function Show(type, bools) {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval;
    if (type == "0") {
        returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectUser.aspx?data=" + ss + "&mode=" + bools, window, "dialogHeight:550px;dialogWidth:900px;status:no;");
    } else {
        returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDeps.aspx?data=" + ss + "&mode=" + bools, window, "dialogHeight:550px;dialogWidth:900px;status:no;");
    }

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        var mh = document.getElementById("<%=this.HIds.ClientID %>");
        var ru = document.getElementById("<%=this.Names.ClientID %>");
        if (mh != null && mh != undefined) {
            document.getElementById("<%=this.HIds.ClientID %>").value = list[0];
        }
        if (ru != null && ru != undefined) {
            document.getElementById("<%=this.Names.ClientID %>").value = list[1];
        }
    }
}
//选择考核单位 选择 部门或公司 或人员 单选或多选
function ShowDeps(bools) {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval;
    returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDep.aspx?data=" + ss + "&mode=" + bools, window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        var mh = document.getElementById("HIds");
        var ru = document.getElementById("Names");
        if (mh != null && mh != undefined) {
            document.getElementById("HIds").value = list[0];
        }
        if (ru != null && ru != undefined) {
            document.getElementById("Names").value = list[1];
        }
    }
}
//选择分管矿领导 选择 部门或公司 或人员 单选或多选
function ShowFkld(bools) {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval;
    returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectFgLDUser.aspx?data=" + ss + "&mode=" + bools, window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        var mh = document.getElementById("HIds");
        var ru = document.getElementById("Names");
        if (mh != null && mh != undefined) {
            document.getElementById("HIds").value = list[0];
        }
        if (ru != null && ru != undefined) {
            document.getElementById("Names").value = list[1];
        }
    }
}

//选择用户
function SelectUsers() {
    Show("0", "0");
}
/* 选择用户方法
 * @param option 参数{MultiSelection:是否为多选 默认值False,NameDom:绑定的Dom,KeyDom:绑定的数据Demo}
 * @param callback 回调对象
 */
function SelectUser(option) {
    var _option = {
        Window: window,
        TextID: "Names",
        ValueID: "HIds"
    };
    if (typeof option != "undefined") {
        if (typeof option.NameDomForID == "string") {
            _option.TextID = option.NameDomForID;
        }
        if (typeof option.KeyDomForID == "string") {
            _option.ValueID = option.KeyDomForID;
        }
    }
    top.MessageBox.OpenUser(_option);
}

/* 选择用户方法
* @param option 参数{MultiSelection:是否为多选 默认值False,NameDom:绑定的Dom,KeyDom:绑定的数据Demo}
* @param callback 回调对象
*/
function ShowRole(option, callback) {
    if (typeof option == "undefined") {
        option = {
            KeyDom: "HId",
            NameDom: "txtRoleName"
        };
    }

    var _option = {
        Window: window,
        TextID: option.NameDom,
        ValueID: option.KeyDom
    };

    top.MessageBox.OpenRole(_option);
    return;
    var _option = {
        Callback: function (obj) {
            document.getElementById("HId").value = obj[1];
            document.getElementById("txtRoleName").value = obj[0];
        }
    };
    if (typeof option != "undefined") {
        if (typeof callback != "undefined") {
            _option.Callback = callback;
        }
        else {
            _option.Callback = function (obj) {
                document.getElementById(option.KeyDom).value = obj[1];
                document.getElementById(option.NameDom).value = obj[0];
            }
        }
    }
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();

    var returnval = window.showModalDialog("/BusinessExpansion/Templete/ManageRole.aspx?", "", "dialogHeight:450px; dialogWidth:600px;");

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('%');
        _option.Callback(list);
    }
}

//多选
function Showd1() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();

    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDep.aspx?data=" + ss + "&mode=2&type=2&ckdep=" + document.getElementById("HId1").value, window, "dialogHeight:550px;dialogWidth:550px;status:no;");

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');

        document.getElementById("HId1").value = list[0];
        document.getElementById("Name1").value = list[1];
    }
}
//多选
function Showd2() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();

    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDep.aspx?data=" + ss + "&mode=2&type=2&ckdep=" + document.getElementById("HId2").value, window, "dialogHeight:550px;dialogWidth:550px;status:no;");

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');

        document.getElementById("HId2").value = list[0];
        document.getElementById("Name2").value = list[1];
    }
}
//单选
function Showd3() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDeps.aspx?data=" + ss + "&mode=0", window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        document.getElementById("HId3").value = list[0];
        document.getElementById("Name3").value = list[1];
    }
}
//单选
function Showd4() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectDeps.aspx?data=" + ss + "&mode=0", window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        document.getElementById("HId4").value = list[0];
        document.getElementById("Name4").value = list[1];
    }
}

function ShowUser1() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var option = {};
    option.Url = "/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2";
    option.Window = this;
    option.CallBack = function (index) {
        try {
            var data = top.frames["layui-layer-iframe" + index].ModalData;
            if (option.Window.document.getElementById("Name1").value != "单击请选择" && data.Text == "") {
            }
            else {
                if (data.Text == "") {
                    data.Text = "单击请选择";
                }
                option.Window.document.getElementById("Name1").value = data.Text;
                option.Window.document.getElementById("HId1").value = data.Value;
            }
        } catch (e) {
        }
    }
    top.MessageBox.OpenUser(option);
    return;

    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2", window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        document.getElementById("HId1").value = list[0];
        document.getElementById("Name1").value = list[1];
    }
}
function ShowUser2() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var option = {};
    option.Window = this;
    option.Url = "/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2";
    option.CallBack = function (index) {
        try {
            var data = top.frames["layui-layer-iframe" + index].ModalData;
            if (option.Window.document.getElementById("Name2").value != "单击请选择" && data.Text == "") {
            }
            else {
                if (data.Text == "") {
                    data.Text = "单击请选择";
                }
                console.log(data);
                option.Window.document.getElementById("Name2").value = data.Text;
                option.Window.document.getElementById("HId2").value = data.Value;
            }
        } catch (e) {
        }
    }
    top.MessageBox.OpenUser(option);
    return;
    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2", window, "dialogHeight:550px;dialogWidth:550px;status:no;");

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        document.getElementById("HId2").value = list[0];
        document.getElementById("Name2").value = list[1];
    }
}
function ShowUser3() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var option = {};
    option.Window = this;
    option.Url = "/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2";
    option.CallBack = function (index) {
        try {
            var data = top.frames["layui-layer-iframe" + index].ModalData;
            if (option.Window.document.getElementById("Name3").value != "单击请选择" && data.Text == "") {
            }
            else {
                if (data.Text == "") {
                    data.Text = "请选择用户";
                }
                console.log(data);
                option.Window.document.getElementById("Name3").value = data.Text;
                option.Window.document.getElementById("HId3").value = data.Value;
            }
        } catch (e) {
        }
    }
    top.MessageBox.OpenUser(option);
    return;
    var returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectUserDr.aspx?data=" + ss + "&mode=1&type=2", window, "dialogHeight:550px;dialogWidth:550px;status:no;");

    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');
        document.getElementById("HId3").value = list[0];
        document.getElementById("Name3").value = list[1];
    }
}

function Showk() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    var returnval;
    returnval = window.showModalDialog("/BusinessExpansion/PublicShow/SelectFgLDUser.aspx?data=" + ss + "&mode=1", window, "dialogHeight:550px;dialogWidth:550px;status:no;");
    //谷歌浏览器兼容
    if (returnval == undefined) {
        returnval = window.returnValue;
    }
    if (returnval != undefined) {
        var str = returnval;
        var list = str.split('|');

        document.getElementById("HIdk").value = list[0];
        document.getElementById("Namek").value = list[1];
    }
}

function Clears() {
    try {
        document.getElementById("HIds").value = "";
        document.getElementById("Names").value = "单击请选择";
    }
    catch (err) { }
}
function Clear1() {
    try {
        document.getElementById("HId1").value = "";
        document.getElementById("Name1").value = "单击请选择";
    }
    catch (err) { }
}
function Clear2() {
    try {
        document.getElementById("HId2").value = "";
        document.getElementById("Name2").value = "单击请选择";
    }
    catch (err) { }
}
function Clear3() {
    try {
        document.getElementById("HId3").value = "";
        document.getElementById("Name3").value = "单击请选择";
    }
    catch (err) { }
}
function Clear4() {
    try {
        document.getElementById("HId4").value = "";
        document.getElementById("Name4").value = "单击请选择";
    }
    catch (err) { }
}
function Cleark() {
    try {
        document.getElementById("HIdk").value = "";
        document.getElementById("Namek").value = "单击请选择";
    }
    catch (err) { }
}

function Cancel() {
    window.close();
}

//GridView
function GetAllCheckBox(CheckAll) {
    var items = document.getElementsByTagName("input");
    for (i = 0; i < items.length; i++) {
        if (items[i].type == "checkbox") {
            items[i].checked = CheckAll.checked;
        }
    }
}
function ValidateEdit() {
    var count = 0;
    var items = document.getElementsByTagName("input");
    for (i = 0; i < items.length; i++) {
        if (items[i].type == "checkbox") {
            if (items[i].checked) {
                count++;
            }
        }
    }
    if (count != 1) {
        if (typeof top.MessageBox == "undefined") {
            alert("请选择要修改的项!最多一项!");
        }
        else {
            top.MessageBox.Alert("请选择要修改的项!最多一项!");
        }
        return false;
    }
    else {
        return true;
    }
}
function IsDelete() {
    var count = 0;
    var items = document.getElementsByTagName("input");
    for (i = 0; i < items.length; i++) {
        if (items[i].type == "checkbox") {
            if (items[i].checked) {
                count++;
            }
        }
    }
    if (count == 0) {
        top.MessageBox.Alert("请选择要删除的项!");
        return;
    }
    else if (count == 1) {
        return confirm("确定要删除吗?");
    }
    else {
        top.MessageBox.Alert("【注意】每次只能删除一项!");
        return;
    }
}
function del() {
    if (confirm("确认删除吗")) {
        alert("yes");
    }
    else {
        alert("no")
        return;
    }
}

//js字符判断
String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function NoNumber() {
    if (event.keyCode == 110) {
        return true;
    }
    if (event.keyCode != 8) {
        if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105))) {
            return false;
        }
    }
    return true;
}

//密码
function IsPwdSame() {
    if (IsNull() == true) {
        var newPwd = document.getElementById("txtNewPassword").value;
        var confirmPassword = document.getElementById("txtConfirmPassword").value;
        if (newPwd != confirmPassword) {
            document.getElementById("txtNewPassword").value = "";
            document.getElementById("txtConfirmPassword").value = "";
            document.getElementById("txtNewPassword").focus();
            alert("两次输入密码不一致，请重新输入!");
        }
    }
}
function IsNull() {
    var newPwd = document.getElementById("txtNewPassword").value;
    var confirmPassword = document.getElementById("txtConfirmPassword").value;
    if (newPwd == "") {
        alert("新密码不能为空!");
        return false;
    }
    if (confirmPassword == "") {
        alert("确认密码不能为空!");
        return false;
    }
    return true;
}

//cookie
function unique(arr) {
    var result = [], hash = {};
    for (var i = 0, elem; (elem = arr[i]) != null; i++) {
        if (!hash[elem]) {
            result.push(elem);
            hash[elem] = true;
        }
    }
    return result;
}
function getcok(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}
var time = null;
function load() {
    time = setInterval("check()", 3000);
    //window.parent.loading();
    ProcessingWindow(true)
}
function check() {
    if (getcok("Load") == "end") {
        //window.parent.loadend();
        //if (parent.MainsIfc.cols != "0,7,0,*") {
        //    clearInterval(time);
        //}
        ProcessingWindow(false)
        clearInterval(time);
    }
}

//弹出层导出EXCEl JS
function ChangeTarget() {
    var anchors = document.getElementsByTagName("base");
    var anchor = anchors[0];
    anchor.target = "baseExportThis";
    return true;
}
function ChangeTarget2() {
    var anchors = document.getElementsByTagName("base");
    var anchor = anchors[0];
    anchor.target = "_self";
    return true;
}

//获取文件
function getFile() {
    document.getElementById("FileUpload1").SELECT();  //选中FileUpload控件中的文本
    var path = document.selection.createRange().text;   //获取当前文本选中的文本
    if (path == "") {
        alert("请先上传文件!");
        return false;
    }
    else {
        document.getElementById("HiddenField1").value = path;
        return true;
    }
}
function SaveFile() {
    document.getElementById("PageOfficeCtrl1").WebSave();
}
//打印
function printPage() {
    var arg = document.getElementById("<%=printargs.ClientID %>").value;
    var args = arg.split('&');
    top.MessageBox.Print(
        {
            Url: "/BusinessExpansion/Print/Business_DetailsPrint.aspx",
            Value: "DI=" + args[0]
        }
    );
    return;
    var result = window.showModalDialog("/BusinessExpansion/Print/Business_DetailsPrint.aspx?DI=" + args[0], "", "dialogHeight:768px; dialogWidth:1024px;");
}
function PrintTable() {
    print();
}

//公用查询按钮事件
function showExcel(uid) {
    try {
        //    var width = screen.width;
        //    var height = screen.height;
        var newTab = window.open('about:blank');
        newTab.location.href = "/UpLoad/" + document.title + uid + ".html";
    } catch (err) { }
}

//调用
function showPTran() {
    var today = new Date(); //获得当前时间
    var ss = today.getSeconds() < 10 ? "0" + today.getSeconds() : today.getSeconds();
    window.showModalDialog("/BusinessExpansion/Templete/JX_PROCEDUREDETAILTran.aspx", "", "dialogHeight:160px; dialogWidth:600px;");
}